package com.ruoyi.web.wx.controller;

import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.department.domain.Department;
import com.ruoyi.department.domain.vo.DepartmentVO;
import com.ruoyi.department.service.IDepartmentService;
import com.ruoyi.disease.domain.Disease;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

@Api(tags = "科室")
@RestController
@RequestMapping("/wx/department")
public class WxDepartmentController extends BaseController {

    @Autowired
    private IDepartmentService departmentService;

    @ApiOperation("查询所有科室信息")
    @GetMapping("getDepartmentInfo/{pageNum}/{pageSize}")
    public AjaxResult getDepartment(@PathVariable Integer pageNum, @PathVariable Integer pageSize) {
        int size = departmentService.selectDepartment1();
        PageHelper.startPage(pageNum, pageSize);
        List<DepartmentVO> departmentVOS1 = departmentService.selectDepartment();
        TableDataInfo dataTable = getDataTable(departmentVOS1);
        dataTable.setTotal(size);
        return AjaxResult.success(dataTable);
    }

    @ApiOperation("查询科室")
    @GetMapping("/getDepartmentList")
    public AjaxResult getDepartmentList() {
        List<Department> departments = departmentService.selectDepartmentList(new Department());
        return AjaxResult.success(departments);
    }

    @ApiOperation("根据科室分页查询病种")
    @GetMapping("/getDiseaseByDepartment")
    public AjaxResult getDiseaseByDepartment(@RequestBody DepartmentVO departmentVO) {
        int i = departmentService.selectDepartmentDiseaseList(departmentVO);
        PageHelper.startPage(departmentVO.getPageNum(), departmentVO.getPageSize());
        List<Disease> diseases = departmentService.selectDiseaseByDepartment(departmentVO);
        TableDataInfo dataTable = getDataTable(diseases);
        dataTable.setTotal(i);
        return AjaxResult.success(dataTable);
    }

    @ApiOperation("搜索疾病")
    @GetMapping("/getIllness/{illness}")
    public AjaxResult getIllness(@PathVariable String illness) {
        return departmentService.getIllness(illness);
    }
}
